package com.tian.arch.base

import android.content.Context
import com.tian.arch.config.showToast

interface Destroyable {
    fun onDestroy()
}

interface IDisplay : Destroyable {
    fun init(context: Context)
    fun showTips(text: String?)
    fun getContext(): Context

    fun showLoadingDialog(message: String? = null)
    fun dismissLoadingDialog()
    fun updateLoadingMessage(loadingText: String)
}

class DisplayDelegate : IDisplay {

    private lateinit var context: Context

    override fun init(context: Context) {
        this.context = context
    }

    override fun showTips(text: String?) {
        showToast(text)
    }

    override fun getContext(): Context {
        return context
    }

    override fun showLoadingDialog(message: String?) {
    }

    override fun dismissLoadingDialog() {
    }

    override fun updateLoadingMessage(loadingText: String) {
    }

    override fun onDestroy() {
    }

}
